package com.nuoniu.sibanyun.mapper.po;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.nuoniu.sibanyun.entity.po.VRoRequisitionOrderMain;
import org.apache.ibatis.annotations.Select;

import java.math.BigDecimal;

/**
 * <p>
 * 请购单主表 Mapper 接口
 * </p>
 *
 * @author baiqiang
 * @since 2020-11-17
 */
public interface VRoRequisitionOrderMainMapper extends BaseMapper<VRoRequisitionOrderMain> {

    @Select("select voucher_code from scp_requisition where date_format(create_date, #{dateStr})=date_format(now(), #{dateStr}) and company_id=#{companyId} order by create_date desc limit 1")
    String getCode(Integer companyId,  String dateStr);


    @Select("select sum(base_quantity) from scp_requisition_detail where id != #{id} and source_detail_id=#{sourceDetailId}")
    BigDecimal getReleasedQuantity(Integer sourceDetailId, Long id);
}
